<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>找工人</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui/aui.css" />
    <style>
        .aui-bar-nav {
            background: #0689FB;
        }

        .aui-searchbar {
            width: auto;
            height: auto;
            background: none;
            padding: 0 .5rem;
            color: white;
        }

        #header {
            display: flex;
            align-items: center;
            background: #F5F5F5;
            padding: .75rem 0;
            justify-content: space-around;
        }

        #header div {
            text-align: center;
        }

        #header div span {
            margin-right: .3rem;
        }

        .triangle {
            padding: 0;
            display: inline-block;
            width: 0;
            height: 0;
            border-right: 0.35rem solid transparent;
            border-left: 0.35rem solid transparent;
            border-top: 0.35rem solid black;
        }

        .aui-list {
            background: rgba(0, 0, 0, 0);
            box-shadow: 0 0 3px #ccc;
        }

        .aui-list .aui-list-item {
            min-height: 1.8rem;
            border-bottom: 1px solid #eeeeee;
            background: rgba(0, 0, 0, 0)
        }

        .aui-list .aui-list-item .aui-media-list-item-inner{width:100%;}

        .aui-list .aui-list-item-inner {
            min-height: 1.8rem;
        }

        .person_info {
            display: flex;
            flex-direction: column;
            justify-content: center;
            font-size: 0.6rem;
            line-height: 1.1rem;
            width: 100%;
        }

        .list_box {
            border-bottom: 1px solid #eeeeee;
            margin-bottom: 1rem;
        }

        .tag {
            background: #0689FB;
            padding: 0 .3rem;
            color: white;
            border-radius: .1rem;
        }

        .iconimg {
            width: 0.6rem;
            display: inline-block;
            vertical-align:sub;
        }

        .aui-list .aui-list-item-media img {
            border: 1px solid #ECECEC;
            border-radius: 100%;
            width: 3rem;
            height: 3rem;
        }

        [v-clock] {
            display: none;
        }
    </style>
</head>

<body>
    <div class="aui-content" id="app" v-clock>
        <header class="aui-bar aui-bar-nav">
            <div class="aui-searchbar" id="search">
                <div class="aui-searchbar-input">
                    <i class="aui-iconfont aui-icon-search"></i>
                    <form action="javascript:search();">
                        <input type="search" placeholder="请输入搜索内容" id="search-input">
                    </form>
                </div>
                <div class="seek" onclick="search()">搜索</div>
            </div>
        </header>
        <div id="header">
            <div class="area" @click="openCity()"><span>{{userRegion.area}}</span><span class="triangle"></span></div>
            <div class="area" @click="openType()"><span>{{workCate.name}}</span><span class="triangle"></span></div>
            <div class="area" @click="openLevel()"><span>{{workCateLevel.name}}</span><span class="triangle"></span></div>
        </div>
        <div class="aui-content-padded" style="margin-bottom:3rem;">
            <div class="aui-list list_box" @click="homepage(data.user_id)" v-for="data in list">
                <div class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title aui-ellipsis-1">{{data.user_introduction}}</div>
                    </div>
                </div>
                <div class="aui-list-item">
                    <div class="aui-media-list-item-inner">
                        <div class="aui-list-item-media">
                            <img :src="data.headimgurl">
                        </div>
                        <div class="person_info">
                            <div>
                                <img src="../../image/icon/menu02-1.png" class="iconimg" alt="">
                                <span>联系人：{{data.user_name}}</span>
                            </div>
                            <div>
                                <img src="../../image/icon/daohang.png" class="iconimg" alt="">
                                <span>{{data.region}}</span>
                            </div>
                            <div style="display:flex;justify-content:space-between;">
                                <div>
                                    <img src="../../image/icon/zhuangtai.png" class="iconimg" alt="">
                                    <span class="tag" v-if='data.is_work == 1'>忙碌中</span>
                                    <span class="tag" v-else-if='data.is_work == 0'>找活中</span>
                                </div>
                                <div style="padding-right:.75rem;">
                                    <img src="../../image/icon/denglu03.png" class="iconimg" alt="" style="width:.8rem;">
                                    <span class="tag" v-if='data.is_insure == 1'>已交众筹金</span>
                                    <span class="tag" v-else-if='data.is_insure == 0'>未交众筹金</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="../../script/api.js" charset="utf-8"></script>
<script src="../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../script/common/common.js" charset="utf-8"></script>
<script src="../../script/common/config.js" charset="utf-8"></script>
<script src="../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    var stateBarH = '';
    apiready = function() {
        api.parseTapmode();

        //沉浸式状态栏
        var systemType = api.systemType;
        var statusBar = api.require('statusBar');
        if (systemType == "ios") {
            if (navigator.userAgent.indexOf("iPhone") != -1) {
                stateBarH = api.safeArea.top;
                $("header").css({
                    "paddingTop": api.safeArea.top + 'px'
                });
            }
        } else {
            statusBar.getStatusBarHeight(function(ret, err) {
                stateBarH = ret.statusHeight;
                $("header").css({
                    "paddingTop": ret.statusHeight
                });
            });
        }

        vm.init();
    }

    var vm = new Vue({
        el: "#app",
        data: {
            userRegion: {},
            workCate: {
                'name': '请选择',
                'id': 0
            },
            workCateLevel: {
                'name': '级别',
                'id': 0
            },
            title: '',
            pages: 1,
            list: [],
        },
        methods: {
            init() {
                this.userRegion = get_local('user_region');
                this.page();
                this.getListData();
            },
            getListData() {
                var self = this;
                _ajax(Config.api.UserGetLists, {
                    region_areaid: self.userRegion.areaid,
                    work_cate_id: self.workCate.id,
                    work_cate_level: self.workCateLevel.id,
                    title: self.title,
                    pages: self.pages
                }, function(res) {
                    if (res.code === 200) {
                        if (res.data.length === 0) {
                            $toast('数据已加载完毕');
                            self.pages = -1;
                        } else {
                            self.list = self.list.concat(res.data);
                        }
                    }
                });
            },
            page() {
                var self = this;
                //上拉加载
                push_up(function() {
                    if (self.pages === -1) {
                        $toast('数据已加载完毕');
                    } else {
                        ++self.pages;
                        self.getListData();
                    }
                });
            },
            openCity() {
                var url = '../city/city_win.html';
                var param = {
                    name: api.winName,
                    frameName: api.frameName,
                    provinceid: this.userRegion.provinceid,
                    cityid: this.userRegion.cityid,
                    areaid: this.userRegion.areaid
                };
                this.openMake(url, param);
            },
            openType() {
                var url = '../city/type_win.html';
                var param = {
                    name: api.winName,
                    frameName: api.frameName
                };
                this.openMake(url, param);
            },
            openLevel() {
                var url = '../city/level_win.html';
                var param = {
                    name: api.winName,
                    frameName: api.frameName
                };
                this.openMake(url, param);
            },
            openMake(url, param = {}) {
                api.openFrame({
                    name: 'mask',
                    url: url,
                    rect: {
                        x: 0,
                        y: stateBarH,
                        w: 'auto',
                        h: 'auto'
                    },
                    bgColor: 'rgba(0,0,0,0.5)',
                    pageParam: param
                });
            },
            homepage(id) {
                if (isLogin()) {
                    open_w('homepage_win', './homepage/homepage_win.html', {
                        id: id
                    });
                }
            }
        }
    });

    function setCity(province, city, area) {
        var data = {
            "provinceid": province.code,
            "province": province.name,
            "cityid": city.code,
            "city": city.name,
            "areaid": area.code,
            "area": area.name
        };
        vm.userRegion = data;
        vm.pages = 1;
        vm.list = [];
        vm.getListData();
    }

    function setType(parentData, childData) {
        if (childData) {
            vm.workCate = {
                name: childData.work_cate_name,
                id: childData.work_cate_id
            }
        } else {
            vm.workCate = {
                'name': '请选择',
                'id': 0
            }
        }

        vm.pages = 1;
        vm.list = [];
        vm.getListData();
    }

    function setLevel(data) {
        if (data) {
            vm.workCateLevel = {
                'name': data.leval_name,
                'id': data.leval_id
            }
        } else {
            vm.workCateLevel = {
                'name': '级别',
                'id': 0
            }
        }

        vm.pages = 1;
        vm.list = [];
        vm.getListData();
    }

    function search() {
        var cont = $('#search-input').val();
        vm.title = cont;

        vm.pages = 1;
        vm.list = [];
        vm.getListData();
    }
</script>

</html>
